//编写代码, 基于 Callable 实现 1+2+3+...+1000

public class demo6 {
    public static int result=0;
    public static void main(String[] args) {
        Thread t1=new Thread(new Runnable() {
            @Override
            public void run() {
                int sum=0;
                for (int i = 0; i <= 1000; i++) {
                    sum=sum+i;
                }
                result=sum;
            }
        });
        t1.start();
        try {
            t1.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(result);
    }
}
